package logic

import (
	"bw-renting/model/mysql"
	"context"
	"encoding/json"

	"bw-renting/house-rpc/house"
	"bw-renting/house-rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetHouseFacilityListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetHouseFacilityListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetHouseFacilityListLogic {
	return &GetHouseFacilityListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// TODO: 房源设施列表
func (l *GetHouseFacilityListLogic) GetHouseFacilityList(in *house.GetHouseFacilityListReq) (*house.Response, error) {
	// todo: add your logic here and delete this line
	res := mysql.GetHouseFacility(in.HouseId)
	if len(res) == 0 {
		return &house.Response{
			Status: "0",
		}, nil
	}
	houses, _ := json.Marshal(res)
	return &house.Response{
		Status: string(houses),
	}, nil
}
